#!/bin/bash
DBDIR=`mktemp -d`
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
#export TMP_EMAIL_DIR=`mktemp -d`
cp ${SCRIPT_DIR}/sendmail ${DBDIR}
chmod 755 ${DBDIR}/sendmail
cd ${DBDIR}
export PATH=${DBDIR}:$PATH
#get latest release version number
release=$(curl -IkLs -o /dev/null -w %{url_effective} https://github.com/pocketbase/pocketbase/releases/latest|grep -o "[^/]*$"| sed "s/v//g")
echo ${release}
wget -qO- https://github.com/pocketbase/pocketbase/releases/download/v${release}/pocketbase_${release}_linux_amd64.zip | bsdtar -xvf- --include pocketbase -C .
chmod 755 ./pocketbase
./pocketbase serve
